<template>
  <div class="marketsupervise">
    <div class="common-tab-box">
      <div :class="{ active: tab === 1 }" @click="tab = 1">安全监管</div>
      <div :class="{ active: tab === 2 }" @click="tab = 2">质量监管</div>
    </div>
    <div class="safelist" v-if="tab === 1">
      <div
        class="safeitem"
        :class="{ small: index > 1 }"
        v-for="(item, index) in dataList"
        :key="index"
      >
        <div class="toptitle">
          <span class="leftname">{{ item.aqjglx }}</span>
          <span class="rightpercent" :class="{ downpercent: item.tb < 0 }"
            >{{ item.tb }}%</span
          >
        </div>
        <div class="bottominfor" v-if="index < 2">
          <div class="leftnum">
            <p class="num">{{ item.sl }}</p>
            <p class="unit">{{ item.dw }}</p>
          </div>
          <div class="rightinfor">
            <p>
              全省第&nbsp;<span>{{ item.qspm }}</span>
            </p>
            <p>
              {{
                index === 0 ? "食品产业规模" : "药品产业规模"
              }}全省第&nbsp;<span>{{ item.qspm }}</span>
            </p>
          </div>
        </div>
        <div class="bottominforother" v-else>
          <div class="leftinfor">
            <b>{{ item.sl }}</b
            >{{ item.dw }}
          </div>
          <div class="rightpaiming">
            全省第&nbsp;<span>{{ item.qspm }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="qslist" v-else>
      <div class="qstitle">知识产权</div>
      <div class="topinfor">
        <div class="left">
          <div class="lefticon"></div>
          <div class="lefttext">{{ qsTopInfor.xm }}</div>
        </div>
        <div class="middlenum">
          <b>{{ qsTopInfor.sl }}</b
          >{{ qsTopInfor.dw }}
        </div>
        <div class="rightpercent" :class="{ greenpercent: qsTopInfor.zj < 0 }">
          {{ qsTopInfor.zj }}%
        </div>
      </div>
      <div class="qstitle">标准工作</div>
      <div class="bottominfor" v-for="(item, index) in qsList" :key="index">
        <div class="lefttext">
          {{ item.xm }}
        </div>
        <div class="rightnumber">
          <p class="topnum">
            <b>{{ item.sl }}</b
            >{{ item.dw }}
          </p>
          <p class="bottompercent" :class="{ greenpercent: item.zj < 0 }">
            <i></i>{{ item.zj }}%
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getAction } from '@/api/manage.js'

export default {
  data() {
    return {
      tab: 1,
      dataList: [],
      qsTopInfor: {},
      qsList: []
    }
  },
  watch: {
    tab() {
      if (this.tab === 1) {
        this.getData()
      } else {
        this.getQsData()
      }
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getQsData() {
      getAction('/topic/data/listAllBySql/dy_app_xxzb_zljg').then((res) => {
        if (res.result && res.result.length > 0) {
          this.qsList = []
          res.result.forEach((element) => {
            if (element.xm.indexOf('专利拥有量') > -1) {
              this.qsTopInfor = element
            } else {
              this.qsList.push(element)
            }
          })
        }
      })
    },
    getData() {
      getAction('/topic/data/listAllBySql/dy_app_xxzb_aqjg').then((res) => {
        if (res.result) {
          this.dataList = res.result
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.safelist {
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  .safeitem {
    width: 199px;
    height: 122px;
    background: url("../images/rightmarket-big-bg.png") no-repeat center;
    background-size: 100% 100%;
    &:nth-child(odd) {
      margin-right: 10px;
    }
    &.small {
      margin-top: 10px;
      height: 78px;
      background: url("../images/rightmarket-small-bg.png") no-repeat center;
      background-size: 100% 100%;
    }
    .toptitle {
      width: 100%;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 8px;
      box-sizing: border-box;
      .leftname {
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #ffffff;
        line-height: 26px;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }
      .rightpercent {
        font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
        font-weight: bold;
        font-size: 14px;
        color: #ff3e3e;
        text-align: right;
        font-style: normal;
        text-transform: none;
        padding-left: 10px;
        box-sizing: border-box;
        position: relative;
        &::before {
          content: "";
          width: 8px;
          height: 12px;
          background: url("../images/up-arrow.png") no-repeat;
          background-size: 100% 100%;
          position: absolute;
          left: 0;
          top: 50%;
          margin-top: -4px;
        }
        &.downpercent {
          color: #18c624;
          &::before {
            content: "";
            width: 8px;
            height: 12px;
            background: url("../images/down-arrow.png") no-repeat;
            background-size: 100% 100%;
            position: absolute;
            left: 0;
            top: 50%;
            margin-top: -5px;
          }
        }
      }
    }
    .bottominfor {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .leftnum {
        width: 103px;
        height: 74px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: url("../images/leftnum-bg.png") no-repeat center;
        background-size: 100% 100%;
        .num {
          font-family: YouSheBiaoTiHei;
          font-size: 24px;
          color: #ffde00;
          line-height: 30px;
          font-style: normal;
          text-transform: none;
        }
        .unit {
          font-family: MicrosoftYaHeiUI;
          font-size: 14px;
          color: #ffffff;
          font-style: normal;
          text-transform: none;
        }
      }
      .rightinfor {
        width: 96px;
        height: 76px;
        background: url("../images/text-bg1.png") no-repeat center;
        background-size: 100% 100%;
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
        line-height: 20px;
        text-align: left;
        font-style: normal;
        text-transform: none;
        display: flex;
        flex-direction: column;
        justify-content: center;
        p {
          span {
            font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
            font-weight: bold;
            font-size: 14px;
            color: #ffde00;
            line-height: 0px;
            text-align: left;
            font-style: normal;
            text-transform: none;
          }
        }
      }
    }
    .bottominforother {
      width: 95%;
      margin: 0 auto;
      padding: 0 10px;
      box-sizing: border-box;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background: url("../images/text-bg2.png") no-repeat center;
      background-size: 100% 100%;
      .leftinfor {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
        text-align: left;
        font-style: normal;
        text-transform: none;
        b {
          font-family: YouSheBiaoTiHei;
          font-size: 24px;
          color: #ffde00;
          line-height: 30px;
          font-style: normal;
          text-transform: none;
        }
      }
      .rightpaiming {
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
        text-align: left;
        font-style: normal;
        text-transform: none;
        span {
          font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
          font-weight: bold;
          font-size: 14px;
          color: #ffde00;
          line-height: 0px;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
    }
  }
}
.qslist {
  width: 100%;
  height: 215px;
  overflow: auto;
  .qstitle {
    width: 100%;
    height: 29px;
    font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    line-height: 29px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    padding: 0 10px;
    box-sizing: border-box;
    background: url("../images/titlebg.png") no-repeat center;
    background-size: 100% 100%;
  }
  .topinfor,
  .bottominfor {
    width: 400px;
    height: 66px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    background: url("../images/depositsAndLoans-bg.png") no-repeat center bottom;
    background-size: 100% 49px;
  }
  .topinfor {
    margin-top: 10px;
    margin-bottom: 10px;
    .left {
      display: flex;
      align-items: center;
      .lefticon {
        width: 103px;
        height: 63px;
        background: url("../images/qsicon.png") no-repeat center;
        background-size: 100% 100%;
        position: relative;
        top: -5px;
      }
      .lefttext {
        font-family: MicrosoftYaHeiUI;
        font-size: 16px;
        color: #f6f9fe;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }
    }
    .middlenum {
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #f6f9fe;
      text-align: left;
      font-style: normal;
      text-transform: none;
      b {
        font-family: YouSheBiaoTiHei;
        font-size: 24px;
        color: #ffde00;
        line-height: 41px;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }
    }
    .rightpercent {
      font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
      font-weight: bold;
      font-size: 14px;
      color: #ff3e3e;
      text-align: right;
      font-style: normal;
      text-transform: none;
      padding-left: 10px;
      box-sizing: border-box;
      position: relative;
      &::before {
        content: "";
        width: 8px;
        height: 12px;
        background: url("../images/up-arrow.png") no-repeat;
        background-size: 100% 100%;
        position: absolute;
        left: 0;
        top: 50%;
        margin-top: -4px;
      }
      &.greenpercent {
        color: #18c624;
        &::before {
          content: "";
          width: 8px;
          height: 12px;
          background: url("../images/down-arrow.png") no-repeat;
          background-size: 100% 100%;
          position: absolute;
          left: 0;
          top: 50%;
          margin-top: -5px;
        }
      }
    }
  }
  .bottominfor {
    .lefttext {
      width: 275px;
      font-family: MicrosoftYaHeiUI;
      font-size: 16px;
      color: #f6f9fe;
      line-height: 24px;
      text-align: left;
      font-style: normal;
      text-transform: none;
    }
    .rightnumber {
      .topnum {
        text-align: right;
        font-family: MicrosoftYaHeiUI;
        font-size: 14px;
        color: #ffffff;
        font-style: normal;
        text-transform: none;
        b {
          font-family: YouSheBiaoTiHei;
          font-size: 24px;
          color: #ffde00;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
      .bottompercent {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        font-family: MicrosoftYaHeiUI, MicrosoftYaHeiUI;
        font-weight: bold;
        font-size: 14px;
        color: #ff3e3e;
        position: relative;
        i {
          width: 8px;
          height: 12px;
          background: url("../images/up-arrow.png") no-repeat;
          background-size: 100% 100%;
        }
        &.greenpercent {
          color: #18c624;
          i {
            width: 8px;
            height: 12px;
            background: url("../images/down-arrow.png") no-repeat;
            background-size: 100% 100%;
          }
        }
      }
    }
  }
}
</style>
